//按摩师
//测试链接：https://leetcode.cn/problems/the-masseuse-lcci/
public class Massage {
    public int massage(int[] nums) {
        int n = nums.length;
        if (n == 0)
            return 0; // 处理边界条件

        int[] f = new int[n];
        int[] g = new int[n];
        f[0] = nums[0];
        for (int i = 1; i < n; i++) {
            f[i] = g[i - 1] + nums[i];
            g[i] = Math.max(f[i - 1], g[i - 1]);
        }
        return Math.max(g[n - 1], f[n - 1]);
    }
}
